/* 
 * inttypes.h
 * This file has no copyright assigned and is placed in the Public Domain.
 * This file is a part of the clang port package.
 * No warranty is given; refer to the file DISCLAIMER within the package.
 *
 * Functions for testing character types and converting characters.
 *
 */

#ifndef _CLANG_PORT_INTTYPES_H_
#define _CLANG_PORT_INTTYPES_H_

/* All the headers include this file. */
#ifndef __IMPL_CLANG_PORT_API_
#	include <_clang_port.h>
#else
#	include <include/_clang_port.h>
#endif

#include <stdint.h>
#include <stddef.h>

#ifndef __IMPL_CLANG_PORT_API_
typedef struct {
	intmax_t quot;
	intmax_t rem;
} imaxdiv_t;
#endif // __IMPL_CLANG_PORT_API_

#ifdef	__cplusplus
extern	"C"	{
#endif
/* 
 * Clang Hook Api.
*/
	typedef intmax_t CLANG_PORT_FPTR_TYPE(imaxabs)(intmax_t);
	extern CLANG_PORT_FPTR_VAR(imaxabs);
	typedef imaxdiv_t CLANG_PORT_FPTR_TYPE(imaxdiv)(intmax_t, intmax_t);
	extern CLANG_PORT_FPTR_VAR(imaxdiv);
	typedef intmax_t CLANG_PORT_FPTR_TYPE(strtoimax)(const char *, char **, int);
	extern CLANG_PORT_FPTR_VAR(imaxabs);
	typedef uintmax_t CLANG_PORT_FPTR_TYPE(strtoumax)(const char *, char **, int);
	extern CLANG_PORT_FPTR_VAR(imaxabs);
	typedef intmax_t CLANG_PORT_FPTR_TYPE(wcstoimax)(const wchar_t *, wchar_t **, int);
	extern CLANG_PORT_FPTR_VAR(imaxabs);
	typedef uintmax_t CLANG_PORT_FPTR_TYPE(wcstoumax)(const wchar_t *, wchar_t **, int);
	extern CLANG_PORT_FPTR_VAR(imaxabs);

#ifndef __IMPL_CLANG_PORT_API_
/*
 * STD C Api.
 */
CLANG_PORT_INLINE intmax_t  imaxabs(intmax_t i)
{
	return CLANG_PORT_CALL_FPTR(imaxabs)(i);
}
CLANG_PORT_INLINE imaxdiv_t imaxdiv(intmax_t i, intmax_t j)
{
	return CLANG_PORT_CALL_FPTR(imaxdiv)(i,j);
}
CLANG_PORT_INLINE intmax_t  strtoimax(const char * str, char ** endptr, int base)
{
	return CLANG_PORT_CALL_FPTR(strtoimax)(str,endptr,base);
}
CLANG_PORT_INLINE uintmax_t strtoumax(const char * str, char ** endptr, int base)
{
	return CLANG_PORT_CALL_FPTR(strtoumax)(str,endptr,base);
}
CLANG_PORT_INLINE intmax_t  wcstoimax(const wchar_t * str, wchar_t ** endptr, int base)
{
	return CLANG_PORT_CALL_FPTR(wcstoimax)(str,endptr,base);
}
CLANG_PORT_INLINE uintmax_t wcstoumax(const wchar_t * str, wchar_t ** endptr, int base)
{
	return CLANG_PORT_CALL_FPTR(wcstoumax)(str,endptr,base);
}
#endif /* __IMPL_CLANG_PORT_API_ */

#ifdef	__cplusplus
}
#endif

#endif /* ndef _CLANG_PORT_INTTYPES_H_ */
